package com.snack.system.domain;

import com.snack.common.core.annotation.Excel;
import com.snack.common.core.utils.StringUtils;
import com.snack.common.core.web.domain.BaseEntity;
import lombok.Data;

import javax.validation.constraints.NotNull;

/**
 * 商品字段数据对象 ts_goods_param_data
 * 
 * @author snack
 * @date 2022-09-18
 */
@Data
public class TsGoodsParamData extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 商品字段数据id */
    private Long goodsParamDataId;

    /** 商品id */
    @Excel(name = "商品id")
    private Long goodsId;

    /** 字段id */
    @NotNull(message = "字段id不能为空")
    @Excel(name = "字段id")
    private Long goodsTypeParamId;

    /** 值 */
    @Excel(name = "值")
    private String val;

    /** 删除标志（0代表存在 2代表删除） */
    private String delFlag;

    /**
     * 商品类型属性
     */
    private TsGoodsTypeParam goodsTypeParam;

    /**
     * 重写equals方法只要goodsParamDataId，goodsTypeParamId相等，我们就认为对象两个相等
     * @param obj
     * @return
     */
    @Override
    public boolean equals(Object obj) {
        if(obj instanceof TsGoodsParamData){
            TsGoodsParamData st=(TsGoodsParamData) obj;
            if (StringUtils.isNull(goodsParamDataId) || StringUtils.isNull(st.goodsParamDataId) || StringUtils.isNull(goodsTypeParamId) || StringUtils.isNull(st.goodsTypeParamId)){
                return false;
            }
            return (goodsParamDataId.equals(st.goodsParamDataId) && goodsTypeParamId.equals(st.goodsTypeParamId));
        }else {
            return super.equals(obj);
        }
    }

    @Override
    public int hashCode() {
        return goodsParamDataId.hashCode() + goodsTypeParamId.hashCode();
    }
}
